<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=windows-1250">
  <title>Folioge Dump</title>
  </head>
  <body>
<?php

$db=new SQLiteDatabase("folioge.db", 0666, $error);

$result=$db->query("select id as id, name from folioge where parent is null;"); 
while($row=$result->fetchObject()){
  $l = 0;
  $id=$row->id;
  $name=$row->name;
  echo '<h4 style="margin:0 0 0 '.$l.'px;"><a href="#'.substr("000000".$id, -7).'">'.$name.'</a></h4>';
  crawl1($id, $db);
}
  
  // recursive function crawls tree
function crawl1($id,$db){ 
  global $s, $l;

  if(!is_null($id)) {
    $result = $db->query("SELECT * FROM folioge where parent=".$id);
    $rows = $result->numRows();
    $s = $s . $id . ",";
    $l = $l + 20;
    for ($i=0; $i<$rows; $i++) {
      $row=$result->fetchObject();
      $id=$row->id;
      $name=$row->name;
      echo '<h4 style="margin:0 0 0 '.$l.'px;"><a href="#'.substr("000000".$id, -7).'">'.$name.'</a></h4>';
      crawl1($id,$db);
    }
    $l = $l - 20;
  } 
}
?>

<br />
<br />

<?php

$result=$db->query("select id as id, name, note from folioge where parent is null;"); 
while($row=$result->fetchObject()){
  $l = 0;
  $id=$row->id;
  $name=$row->name;
  $note=$row->note;
  echo '<h4><a name="'.substr("000000".$id, -7).'">'.$name.'</a></h4>'.$note;
  crawl2($id, $db);
}
  
  // recursive function crawls tree
function crawl2($id,$db){ 
  global $s, $l;

  if(!is_null($id)) {
    $result = $db->query("SELECT * FROM folioge where parent=".$id);
    $rows = $result->numRows();
    $s = $s . $id . ",";
    $l = $l + 20;
    for ($i=0; $i<$rows; $i++) {
      $row=$result->fetchObject();
      $id=$row->id;
      $name=$row->name;
      $note=$row->note;
      echo '<h4><a name="'.substr("000000".$id, -7).'">'.$name.'</a></h4> '.$note;
      crawl2($id,$db);
    }
    $l = $l - 20;
  } 
}


?>

</body>
</html>
